package lijun;

import cn.hutool.core.collection.CollectionUtil;
import org.apache.commons.collections4.CollectionUtils;

import javax.swing.text.html.parser.Entity;
import java.util.HashMap;
import java.util.Map;

public class strTest {
    public static void main(String[] args) {
        String s = "AbC123sdfg7fFCM987D0ddFFPAZvvvFFFggg43";
        System.out.println(s.substring(5, 10));

        Map<String, Integer> map = new HashMap<>();
        for (char c : s.toCharArray()) {
            String key = String.valueOf(c);
            if (map.get(key) == null) {
                map.put(key, 1);
            } else {
                map.put(key, map.get(key) + 1);
            }
        }
        System.out.println(map.keySet());
        System.out.println(map.values());

        int min = 100;
        int max = -1;
        String minC="";
        String maxC="";
        for (Map.Entry<String, Integer> entry : map.entrySet()) {
            if (entry.getValue()>max){
                max = entry.getValue();
                maxC = entry.getKey();
            }
            if (entry.getValue()<min){
                min = entry.getValue();
                minC = entry.getKey();
            }
        }
        System.out.println("最少次数的字符:"+minC + " "+min);
        System.out.println("最多次数的字符:"+maxC + " "+max);

        String s1 = s.replaceAll(maxC, "#");
        System.out.println(s1);

        String s3 = new StringBuilder(s1).reverse().toString();
        System.out.println(s3);

    }

}
